import axios from 'axios'
import {getToken} from './auth.js'
// let baseURL=process_env.REACT_APP_URL
let req=axios.create({
    baseURL:'http://localhost:8080',
    timeout:10*1000
})

req.interceptors.request.use(config=>{

    const { url } = config
    if (
        url.startsWith('/user') &&
        !url.startsWith('/user/login') &&
        !url.startsWith('/user/registered')
    ) {
        // 添加请求头
        config.headers.Authorization = getToken()
    }

    return config
})

req.interceptors.response.use(rep=>{

    return rep
})

export default req